<?php

require_once(WSB_MODULES_PATH . 'cms/models/Xtensions.php');
require_once(WSB_MODULES_PATH . 'cms/models/Xtension.php');

class Cms_Model_DbTable_Xtension extends WSB_Db_Table
{

    protected $_name = 'instance';
    protected $_primary = 'id';
    protected $_rowsetClass = 'Cms_Model_Xtensions';
    protected $_rowClass = 'Cms_Model_Xtension';
    protected $_dependentTables = array();

	protected $_order = 'name ASC';
	protected $_listcols = array('id', 'name', 'class');

	/**
	 * @return array
	 */
	public static function getDescriptors()
	{
		// Alle description.xml Dateien im Verzeichnis Module auslesen
		$descriptors = array();
		$xtensionPath = WSB_XTENSION_PATH;
		$d = dir($xtensionPath);
		while (false !== ($entry = $d->read())) {
			$descriptorPath = $xtensionPath . $entry . '/etc/descriptor.xml';
			if(is_readable($descriptorPath)) {
				array_push($descriptors, simplexml_load_file($descriptorPath, 'Cms_Model_XtensionDescriptor'));
			}
		}
		$d->close();
		return $descriptors;
	}

}
